<%@page import="java.util.List"%>
<%@page import="com.cqeec.myblog.model.Article"%>
<%@ page import="com.cqeec.myblog.service.ArticleServiceImpl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="include/resources.jsp"%>
<title>我的博客</title>
<script type="text/javascript" src="./js/index.js"></script>
</head>
<body>
	<div class="container-fluid">
		<%@include file="include/header.jsp"%>
		<div class="row">
			<div class="col-sm-8">
				<%-- 创建博文 --%>

				<%
					if (blogger != null) {
				%>
				<br />
				<button class="btn btn-primary" id="createArticle">创建文章</button>
				<br />
				<%
					}
				%>

				<%-- 博文列表 --%>
				<%-- 输出10篇文章 --%>
				<%
					Object obj = request.getAttribute("list");
					if (obj != null) {
						List<Article> list = (List<Article>) obj;
						for (Article a : list) {
				%>
				<br />
				<div class="card">
					<div class="card-body">
						<a href="" target="_blank">
							<h5 class="card-title"><%=a.getTitle()%></h5>
							<p class="card-text"><%=a.getContent()%></p>
						</a>
						<div style="margin-top: 10px;">
							<span class="align-middle" style="color: #ccc;">发布时间：<%=a.getCreationTime()%></span>
							<%
							    request.setAttribute("id", a.getId());
								if (blogger != null) {
							%>
							<a href="#" target="_parent" class="btn btn-danger float-right delete_article" 
								id="${id}" style="margin-left: 10px;">删除文章</a> <a href="/MyBlog/articleServlet?operation=updatePage&articleId=${id}" target="_blank"
								class="btn btn-info float-right" style="margin-left: 10px;">修改文章</a>
							<%
								}
							%>
							<a href="/MyBlog/articleServlet?operation=readArticle&articleId=${id}" target="_blank" class="btn btn-primary float-right">阅读全文</a>
						</div>
					</div>
				</div>
				<%
					}
					}
				%>
			</div>
			<div class="col-sm-4">
				<%-- 博文分类标签 --%>
				<br />
				<h5>文章分类标签</h5>
				<ul class="list-group">
					<li
						class="list-group-item d-flex justify-content-between align-items-center">
						Cras justo odio <span class="badge badge-primary badge-pill">14</span>
					</li>
					<li
						class="list-group-item d-flex justify-content-between align-items-center">
						Dapibus ac facilisis in <span
						class="badge badge-primary badge-pill">2</span>
					</li>
					<li
						class="list-group-item d-flex justify-content-between align-items-center">
						Morbi leo risus <span class="badge badge-primary badge-pill">1</span>
					</li>
				</ul>
			</div>
		</div>
		<div class="row" style="margin: 20px 0px;">
			<div class="col">
				<p class="text-center">&copy;2018&nbsp;&nbsp;&nbsp;重庆信息技术职业学院&nbsp;&nbsp;&nbsp;软件学院&nbsp;&nbsp;&nbsp;软件开发教研室&nbsp;&nbsp;&nbsp;唐礼飞</p>
			</div>
		</div>
	</div>
</body>
</html>